class Solution
{
public:
    int maxEqualRowsAfterFlips(vector<vector<int>> &matrix)
    {
        map<vector<int>, int> patternCount;
        for (auto &row : matrix)
        {
            if (row[0] == 1)
            {
                for (int &i : row)
                {
                    i = 1 - i;
                }
            }
            ++patternCount[row];
        }
        int result = 0;
        for (auto &[_, count] : patternCount)
        {
            result = max(result, count);
        }
        return result;
    }
};